/*
 * httpmsg.h
 *
 *  Created on: Apr 14, 2009
 *      Author: kuncai
 */

#ifndef HTTPMSG_H_
#define HTTPMSG_H_

#include <map>
#include <string>
using namespace std;
#include <string.h>
#include <stdlib.h>
#include "log.h"
#include "buffer.h"
namespace Http{
	static const char* Server = "Server";	
	static const char* Dates = "Date";	
	static const char* LastModified = "Last-Modified";	
	static const char* IfModifiedSince = "If-Modified-Since";	
	static const char* AcceptEncoding = "Accept-Encoding";	
	static const char* AcceptCharset = "Accept-Charset";	
	static const char* ContentEncoding = "Content-Encoding";	
	static const char* Utf8 = "utf-8";	
	static const char* Gb2312 = "gb2312";	
	static const char* Gzip = "gzip";	
	static const char* Deflate = "deflate";	
	static const char* Any = "*";	
}
class HttpMsg
{
public:
	HttpMsg();
	HttpMsg(string msg);
	~HttpMsg();
	int SetHeader(string name, string value);
	string GetHeader(string name);
	Buffer* GetContent();
	int SetContent(Buffer* content);
	int HttpSpilt_q(string qMsg, map<string,float>* qList); 
	/*
	 * 以第一个needle为界，返回needle前的字符串。
	 * 并将原字符串置到needle后的位置
	 */
	string strspilt(string* str, string needle);
	virtual Buffer ToBuffer()=0;
protected:
	string sMsg;
	map<string,string> mHeaderList;
	Buffer sContent;
};
#endif /* HTTPMSG_H_ */
